import { getEnvConfig } from "../../../utils/iocUtils";
import { getCurrentOrganizationId } from "../../../utils/utils";
var organizationId = getCurrentOrganizationId();

var _getEnvConfig = getEnvConfig(),
    CPAAS_PLATFORM = _getEnvConfig.CPAAS_PLATFORM;

export default (function (_ref) {
  var searchCode = _ref.searchCode;
  return {
    paging: false,
    autoQuery: false,
    primaryKey: 'searchId',
    transport: {
      read: function read() {
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/search-config?searchCode=").concat(searchCode),
          method: 'get'
        };
      },
      destroy: function destroy(_ref2) {
        var data = _ref2.data;
        return {
          url: "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/search-config/").concat(data[0].searchId),
          data: data[0],
          method: 'delete'
        };
      }
    },
    fields: [{
      name: 'searchName',
      type: 'string'
    }, {
      name: 'searchId',
      type: 'number'
    }, {
      name: 'searchCode',
      type: 'string'
    }, {
      name: 'queryModified',
      type: 'boolean',
      ignore: 'always',
      defaultValue: false
    }]
  };
});